home *** CD-ROM | disk | FTP | other *** search
/ Tux Racer / Tux Racer.iso / program files / Sunspire Studios / Tux Racer / tcllib / sounds.tcl < prev   
Encoding:
Text File  |  2001-12-05  |  1.5 KB  |  62 lines

  1.  
  2. namespace eval TRSounds {
  3.     # For each directoy in $path, a new action is created with the name of
  4.     # that directory, and all the sounds in that directory are assocsiated
  5.     # with the action.
  6.     proc Load { path soundtype } {
  7.     set olddir [pwd]
  8.     cd $path
  9.     foreach dir [glob -nocomplain *] {
  10.         if { ![file isdir $dir] } {
  11.         continue
  12.         }
  13.         if {[string toupper $dir] == "CVS"} {
  14.         continue
  15.         }
  16.  
  17.         set soundlist []
  18.  
  19.         set dir [string tolower $dir]
  20.         
  21.         objcreate s_container ":sounds:$dir"
  22.  
  23.         cd $dir
  24.  
  25.         set extra_settings ""
  26.         
  27.         foreach sound [glob *] {
  28.         if { [string tolower $sound] == "settings.txt" } {
  29.             # Get loop count from file
  30.             if [catch {open $sound r} fileId] {
  31.             tux_warning "Couldn't open $sound";
  32.             } else {
  33.             while { ![eof $fileId] } {
  34.                 gets $fileId setting 
  35.                 set extra_settings "$extra_settings $setting"
  36.             }
  37.             close $fileId
  38.             }
  39.             continue;
  40.         }
  41.  
  42.         if { ![string match -nocase "*.wav" $sound] } {
  43.             continue
  44.         }
  45.         set soundname [string range $sound 0 \
  46.             [expr [string length $sound] - 5]]
  47.         set soundname [string tolower $soundname]
  48.         objcreate "s_$soundtype" :sounds:$dir:$soundname \
  49.             -filename $sound
  50.         
  51.         lappend soundlist :sounds:$dir:$soundname
  52.         }
  53.  
  54.         eval objcreate "s_action_\$soundtype" :actions:sounds:\$dir \
  55.             -sounds \$soundlist $extra_settings
  56.  
  57.         cd ..
  58.     }
  59.     cd $olddir
  60.     }
  61. }; # namespace TRSounds
  62.